package com.oba.base.dao;

import java.util.List;
import java.util.Map;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.CallableStatementCallback;
import org.springframework.jdbc.core.CallableStatementCreator;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.StatementCallback;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.jdbc.support.rowset.SqlRowSet;

import com.oba.base.dao.JdbcDaoSupportImpl;

public class JdbcDao {
	
	private JdbcDaoSupportImpl jdao;

	public void setJdao(JdbcDaoSupportImpl jdao) {
		this.jdao = jdao;
	} 
	
	/**
	 * Issue multiple SQL updates on a single Statement, using JDBC 2.0
	 * batching.
	 */
	public int[] batchUpdate(String[] sql) {
		return jdao.getJdbcTemplate().batchUpdate(sql);
	}

	/**
	 * Issue multiple updates on a single PreparedStatement, using JDBC 2.0
	 * batch updates and a BatchPreparedStatementSetter to set values.
	 */
	public int[] batchUpdate(String sql, BatchPreparedStatementSetter pss) {
		return jdao.getJdbcTemplate().batchUpdate(sql, pss);
	}

	/**
	 * Execute a SQL call using a CallableStatementCreator to provide SQL and
	 * any required parameters.
	 */
	public Map call(CallableStatementCreator csc, List declaredParameters) {
		return jdao.getJdbcTemplate().call(csc, declaredParameters);
	}

	/**
	 * Execute a JDBC data access operation, implemented as callback action
	 * working on a JDBC CallableStatement.
	 */
	public Object execute(CallableStatementCreator csc,
			CallableStatementCallback action) {
		return jdao.getJdbcTemplate().execute(csc, action);
	}

	/**
	 * Execute a JDBC data access operation, implemented as callback action
	 * working on a JDBC Connection.
	 */
	public Object execute(ConnectionCallback action) {
		return jdao.getJdbcTemplate().execute(action);
	}

	/**
	 * Execute a JDBC data access operation, implemented as callback action
	 * working on a JDBC PreparedStatement.
	 */
	public Object execute(PreparedStatementCreator psc,
			PreparedStatementCallback action) {
		return jdao.getJdbcTemplate().execute(psc, action);
	}

	/**
	 * Execute a JDBC data access operation, implemented as callback action
	 * working on a JDBC Statement.
	 */
	public Object execute(StatementCallback action) {
		return jdao.getJdbcTemplate().execute(action);
	}

	/**
	 * Issue a single SQL execute, typically a DDL statement.
	 */
	public void execute(String sql) {
		jdao.getJdbcTemplate().execute(sql);

	}

	/**
	 * Execute a JDBC data access operation, implemented as callback action
	 * working on a JDBC CallableStatement.
	 */
	public Object execute(String callString, CallableStatementCallback action) {
		return jdao.getJdbcTemplate().execute(callString, action);
	}

	/**
	 * Execute a JDBC data access operation, implemented as callback action
	 * working on a JDBC PreparedStatement.
	 * 
	 */
	public Object execute(String sql, PreparedStatementCallback action) {
		return jdao.getJdbcTemplate().execute(sql, action);
	}

	/**
	 * Query using a prepared statement, reading the ResultSet on a per-row
	 * basis with a RowCallbackHandler (potentially implementing the
	 * ResultReader sub-interface that provides a result List).
	 */
	public void query(PreparedStatementCreator psc, RowCallbackHandler rch) {
		jdao.getJdbcTemplate().query(psc, rch);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, reading the ResultSet with a
	 * ResultSetExtractor.
	 */
	public Object query(String sql, Object[] args, int[] argTypes,
			ResultSetExtractor rse) {
		return jdao.getJdbcTemplate().query(sql, args, argTypes, rse);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, reading the ResultSet on a per-row basis
	 * with a RowCallbackHandler (potentially implementing the ResultReader
	 * sub-interface that provides a result List).
	 */
	public void query(String sql, Object[] args, int[] argTypes,
			RowCallbackHandler rch) {
		jdao.getJdbcTemplate().query(sql, args, argTypes, rch);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, reading the ResultSet with a
	 * ResultSetExtractor.
	 */
	public Object query(String sql, Object[] args, ResultSetExtractor rse) {
		return jdao.getJdbcTemplate().query(sql, args, rse);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, reading the ResultSet on a per-row basis
	 * with a RowCallbackHandler (potentially implementing the ResultReader
	 * sub-interface that provides a result List).
	 */
	public void query(String sql, Object[] args, RowCallbackHandler rch) {
		jdao.getJdbcTemplate().query(sql, args, rch);
	}

	/**
	 * Query using a prepared statement, reading the ResultSet with a
	 * ResultSetExtractor.
	 */
	public Object query(String sql, PreparedStatementSetter pss,
			ResultSetExtractor rse) {
		return jdao.getJdbcTemplate().query(sql, pss, rse);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a
	 * PreparedStatementSetter implementation that knows how to bind values to
	 * the query, reading the ResultSet on a per-row basis with a
	 * RowCallbackHandler (potentially implementing the ResultReader
	 * sub-interface that provides a result List).
	 */

	public void query(String sql, PreparedStatementSetter pss,
			RowCallbackHandler rch) {
		jdao.getJdbcTemplate().query(sql, pss, rch);
	}

	/**
	 * Execute a query given static SQL, reading the ResultSet with a
	 * ResultSetExtractor.
	 */

	public Object query(String sql, ResultSetExtractor rse) {
		return jdao.getJdbcTemplate().query(sql, rse);
	}

	/**
	 * Execute a query given static SQL, reading the ResultSet on a per-row
	 * basis with a RowCallbackHandler (potentially implementing the
	 * ResultReader sub-interface that provides a result List).
	 */
	public void query(String sql, RowCallbackHandler rch) {
		jdao.getJdbcTemplate().query(sql, rch);
	}
	
	public List query(String sql,RowMapper rowMapper){
		return jdao.getJdbcTemplate().query(sql, rowMapper);
	}
	

	/**
	 * Execute a query that results in an int value, given static SQL.
	 */
	public int queryForInt(String sql) {
		return jdao.getJdbcTemplate().queryForInt(sql);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, resulting in an int value.
	 */
	public int queryForInt(String sql, Object[] args) {
		return jdao.getJdbcTemplate().queryForInt(sql, args);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, resulting in an int value.
	 */
	public int queryForInt(String sql, Object[] args, int[] argTypes) {
		return jdao.getJdbcTemplate().queryForInt(sql, args, argTypes);
	}

	/**
	 * Execute a query for a result list, given static SQL.
	 */
	public List queryForList(String sql) {
		return jdao.getJdbcTemplate().queryForList(sql);
	}

	/**
	 * Execute a query for a result list, given static SQL.
	 */
	public List queryForList(String sql, Class elementType) {
		return jdao.getJdbcTemplate().queryForList(sql, elementType);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result list.
	 */
	public List queryForList(String sql, Object[] args) {
		return jdao.getJdbcTemplate().queryForList(sql, args);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result list.
	 */
	public List queryForList(String sql, Object[] args, Class elementType) {
		return jdao.getJdbcTemplate().queryForList(sql, args, elementType);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result list.
	 */
	public List queryForList(String sql, Object[] args, int[] argTypes) {
		return jdao.getJdbcTemplate().queryForList(sql, args, argTypes);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result list.
	 */
	public List queryForList(String sql, Object[] args, int[] argTypes,
			Class elementType) {
		return jdao.getJdbcTemplate().queryForList(sql, args, argTypes,
				elementType);
	}

	/**
	 * Execute a query that results in a long value, given static SQL.
	 */
	public long queryForLong(String sql) {
		return jdao.getJdbcTemplate().queryForLong(sql);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, resulting in a long value.
	 */

	public long queryForLong(String sql, Object[] args) {
		return jdao.getJdbcTemplate().queryForLong(sql, args);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, resulting in a long value.
	 */
	public long queryForLong(String sql, Object[] args, int[] argTypes) {
		return jdao.getJdbcTemplate().queryForLong(sql, args, argTypes);
	}

	/**
	 * Execute a query for a result Map, given static SQL.
	 */

	public Map queryForMap(String sql) {
		return jdao.getJdbcTemplate().queryForMap(sql);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result Map.
	 */
	public Map queryForMap(String sql, Object[] args) {
		return jdao.getJdbcTemplate().queryForMap(sql, args);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result Map.
	 */
	public Map queryForMap(String sql, Object[] args, int[] argTypes) {
		return jdao.getJdbcTemplate().queryForMap(sql, args, argTypes);
	}

	/**
	 * Execute a query for a result object, given static SQL.
	 */
	public Object queryForObject(String sql, Class requiredType) {
		return jdao.getJdbcTemplate().queryForObject(sql, requiredType);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result object.
	 */
	public Object queryForObject(String sql, Object[] args, Class requiredType) {
		return jdao.getJdbcTemplate().queryForObject(sql, args, requiredType);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a result object.
	 */
	public Object queryForObject(String sql, Object[] args, int[] argTypes,
			Class requiredType) {
		return jdao.getJdbcTemplate().queryForObject(sql, args, argTypes,
				requiredType);
	}

	/**
	 * Execute a query for a SqlRowSet, given static SQL.
	 */
	public SqlRowSet queryForRowSet(String sql) {
		return jdao.getJdbcTemplate().queryForRowSet(sql);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a SqlRowSet.
	 */
	public SqlRowSet queryForRowSet(String sql, Object[] args) {
		return jdao.getJdbcTemplate().queryForRowSet(sql, args);
	}

	/**
	 * Query given SQL to create a prepared statement from SQL and a list of
	 * arguments to bind to the query, expecting a SqlRowSet.
	 */
	public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes) {
		return jdao.getJdbcTemplate().queryForRowSet(sql, args, argTypes);
	}

	/**
	 * Issue an update using a PreparedStatementCreator to provide SQL and any
	 * required parameters.
	 */
	public int update(PreparedStatementCreator psc) {
		return jdao.getJdbcTemplate().update(psc);
	}

	/**
	 * Issue an update using a PreparedStatementCreator to provide SQL and any
	 * required parameters.
	 */
	public int update(PreparedStatementCreator psc, KeyHolder generatedKeyHolder) {
		return jdao.getJdbcTemplate().update(psc, generatedKeyHolder);
	}

	/**
	 * Issue a single SQL update.
	 */
	public int update(String sql) {
		return jdao.getJdbcTemplate().update(sql);
	}

	/**
	 * Issue an update via a prepared statement, binding the given arguments.
	 */
	public int update(String sql, Object[] args) {
		return jdao.getJdbcTemplate().update(sql, args);
	}

	/**
	 * Issue an update via a prepared statement, binding the given arguments.
	 */
	public int update(String sql, Object[] args, int[] argTypes) {
		return jdao.getJdbcTemplate().update(sql, args, argTypes);
	}

	/**
	 * Issue an update using a PreparedStatementSetter to set bind parameters,
	 * with given SQL.
	 */
	public int update(String sql, PreparedStatementSetter pss) {
		return jdao.getJdbcTemplate().update(sql, pss);
	}

}
